package cn.zlj.nmcc.web.controller;

import cn.zlj.nmcc.domain.LoginDto;
import cn.zlj.nmcc.result.JSONResult;
import cn.zlj.nmcc.service.VerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/verifyCode")
public class VerifyCodeController {
    @Autowired
    private VerifyCodeService verifyCodeService;

    @GetMapping("/imageCode/{key}")
    public JSONResult verifyCode(@PathVariable("key") String key){
        String code = verifyCodeService.verifyCode(key);
        return JSONResult.success(code);
    }
    @PostMapping("/sendSmsCode")
    public JSONResult sendSmsCode(@RequestBody @Valid LoginDto loginDto){
         verifyCodeService.sendSmsCode(loginDto);
        return JSONResult.success();
    }


}
